Contents
https://towardsdatascience.com/data-visualization-with-bokeh-in-python-part-ii-interactions-a4cf994e2512
from pathlib import Path
import scipy
import numpy as np
import pandas as pd
import plotly.express as px
import plotly.graph_objects as go
from plotly.subplots import make_subplots
filepath = "/Users/kperks/mnt/PerksLab_rstore/neurophysiology_lab/CockroachLeg/CockroachLeg_40k2021-07-04T09_41_21.bin"
number_channels = 1
sampling_rate = 40000
downsample = True #@param
#@markdown After you have filled out all form fields,
#@markdown run this code cell to load the data.
filepath = Path(filepath)
# No need to edit below this line
#################################
data = np.fromfile(Path(filepath), dtype = np.float64)
if number_channels>1:
data = data.reshape(-1,number_channels)
dur = np.shape(data)[0]/sampling_rate
print('duration of recording was %0.2f seconds' %dur)
fs = 1/sampling_rate
if downsample:
newfs = 2500 #downsample emg data
chunksize = int(sampling_rate/newfs)
if number_channels>1:
data = data[0::chunksize,:]
if number_channels==1:
data = data[0::chunksize]
fs = np.shape(data)[0]/dur
time = np.linspace(0,dur,np.shape(data)[0])
print('Now be a bit patient while it plots.')
fig = go.Figure()
fig.add_trace(go.Scatter(x = time, y = data,line_color='black',name='channel 1'))
fig.update_layout(xaxis_title="time(seconds)", yaxis_title='amplitude',width=800, height=500)
fig.show()
duration of recording was 193.50 seconds
Now be a bit patient while it plots.